package project;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class UITestFrame extends JFrame implements ActionListener
{
	private JPanel bigButtonP = null, mainP = null;
	private JButton addClientB = null, lookClientB = null,
					spareB = null;
	AddClientPanel acp;
	//private JPanel mainP = null, buttonP = null, westP = null;
	//private JButton editB = null;
	
	public UITestFrame()
	{
		
	//	DetailsPanel dp = new DetailsPanel();
	//	AddressPanel ap1 = new AddressPanel("Residential");
	//	AddressPanel ap2 = new AddressPanel("Postal");
		spareB = new JButton();
		bigButtonP = new JPanel(new GridLayout(1,2));
		addClientB = new JButton("Add New Client");
		addClientB.addActionListener(this);
		lookClientB = new JButton("Look Up Client");
		lookClientB.addActionListener(this);
		bigButtonP.add(lookClientB);
		bigButtonP.add(addClientB);
		//addClientB.setEnabled(false);
		//addClientB.setBackground(Color.GREEN);
		bigButtonP.setPreferredSize(new Dimension(780, 30));
		/*buttonP = new JPanel();
		editB = new JButton("Edit Details");
		buttonP.add(editB);
		buttonP.setBorder(BorderFactory.createEtchedBorder());
		mainP = new JPanel(new BorderLayout());
		mainP.add(dp, BorderLayout.NORTH);
		mainP.add(ap1, BorderLayout.CENTER);
		mainP.add(ap2, BorderLayout.SOUTH);
		westP = new JPanel(new BorderLayout());
		westP.add(mainP, BorderLayout.CENTER);
		westP.add(buttonP, BorderLayout.SOUTH);
		westP.setPreferredSize(new Dimension(220,450));
		westP.setBorder(BorderFactory.createEmptyBorder(5,0,10,0));
		
		PhotoPanel pp = new PhotoPanel();*/
		
		mainP = new JPanel(new GridLayout(1,1));
		LookClientPanel lcp = new LookClientPanel();
		lookClientB.setBackground(Color.LIGHT_GRAY);
		mainP.add(lcp);
		
		this.setTitle("New Client");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().add(bigButtonP, BorderLayout.NORTH);
		this.getContentPane().add(mainP, BorderLayout.CENTER);
		this.setSize(800,600);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
		
		
	}
	
	public void actionPerformed(ActionEvent e)
	{
		Object source = e.getSource();
		if(source == lookClientB)
		{
			LookClientPanel lcp = new LookClientPanel();
			addClientB.setBackground(spareB.getBackground());
			lookClientB.setBackground(Color.LIGHT_GRAY);
			mainP.removeAll();
			mainP.add(lcp);
			this.validate();
			this.repaint();
		}
		if(source == addClientB)
		{
			acp = new AddClientPanel();
			lookClientB.setBackground(spareB.getBackground());
			addClientB.setBackground(Color.LIGHT_GRAY);
			mainP.removeAll();
			mainP.add(acp);
			this.validate();
			this.repaint();
		}
	}
	public static void main(String [] args)
	{
		new UITestFrame();
	}
}